/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.wanhai.itm.wditm141.vm;

import com.wanhai.itm.wditm141.service.WDITM141_Service;
import com.wanhai.vo.itm.ITM4005VO;
import com.wanhai.vo.itm.ITM4007VO;
import com.wanhai.vo.itm.ITM4008VO;
import com.wanhai.zkbase.core.WHL_BaseVM;
import java.util.ArrayList;
import java.util.List;
import org.zkoss.bind.annotation.AfterCompose;
import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.ContextParam;
import org.zkoss.bind.annotation.ContextType;
import org.zkoss.bind.annotation.Init;
import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.util.resource.Labels;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.CheckEvent;
import org.zkoss.zk.ui.select.Selectors;
import org.zkoss.zk.ui.select.annotation.Wire;
import org.zkoss.zul.Include;
import org.zkoss.zul.Window;

/**
 *
 * @author m2434
 */
public class WDITM141_VM extends WHL_BaseVM{
    private List<ITM4005VO> items = new ArrayList<ITM4005VO>();
    private List<ITM4007VO> fileItems = new ArrayList<ITM4007VO>();
    private List<ITM4008VO> rankItems = new ArrayList<ITM4008VO>();
    private List<ITM4008VO> fullRankItems = new ArrayList<ITM4008VO>();
    
    private ITM4005VO cond = new ITM4005VO();//query condition;
    private ITM4005VO selected;
    private ITM4008VO rankItemSelected;
    private int selectedIndex;
    private List<ITM4005VO> selecteds = new ArrayList<ITM4005VO>();
    private List<ITM4008VO> fullRankItemSelecteds = new ArrayList<ITM4008VO>();
    
    private String actionFlag;
    
    private WDITM141_Service service;
    
     ///<editor-fold defaultstate="collapsed" desc="binding UI component">
    @Wire("#inc1")
    private Include inc1;
    //</editor-fold>

    public WDITM141_VM(){
        setProgTitle(Labels.getLabel("itm141.label.program_title"));
        setProgCode("WDITM141");
    }
    
//    @Init(superclass = true)
//    public void init(){
//        service = new Wditm141Service(this);
//
//        //初始化下拉選單內容
////        dayOfWeekList = service.getLoadOption().getDayOfWeek();
////        pmOffList = service.getLoadOption().getYesOrNo();
//    }
    
    @Command
    public void preInsert(){
        this.setActionFlag("insert");
        
          ((Window)inc1.getFellow("operatorWin")).doModal();
    }
    
    @AfterCompose
    public void afterCompose(@ContextParam(ContextType.VIEW) Component view){
        Selectors.wireComponents(view, this, false);
    }
    
    @Command("addToRankItems")
    @NotifyChange({"rankItems","fullRankItems"})
    public void addToRankItems(){
        for(ITM4008VO vo : this.getFullRankItemSelecteds()){
            this.getRankItems().add(vo);
        }
        this.getFullRankItemSelecteds().clear();
    }
    
    @Command("removeFromRankItems")
    @NotifyChange({"rankItems"})
    public void removeFromRankItems(){
            this.getRankItems().remove(this.getRankItemSelected());
    }
    
    @Command("upDownMove")
    @NotifyChange({"rankItems"})
    public void upDownMove(@BindingParam("upOrDown") int upOrDown){
        int index = this.getRankItems().indexOf(this.getRankItemSelected());
        System.out.println("index = "+index);
        
        this.getRankItems().set(index , this.getRankItems().get(index + upOrDown));
        this.getRankItems().set(index + upOrDown , this.getRankItemSelected());
    }
    
    
    
    
    
    //<editor-fold defaultstate="collapsed" desc="getter , setter">
    public List<ITM4005VO> getItems() {
        return items;
    }
    
    public void setItems(List<ITM4005VO> items) {
        this.items = items;
    }

    public List<ITM4007VO> getFileItems() {
        return fileItems;
    }

    public void setFileItems(List<ITM4007VO> fileItems) {
        this.fileItems = fileItems;
    }
    
    public ITM4005VO getCond() {
        return cond;
    }

    public void setCond(ITM4005VO cond) {
        this.cond = cond;
    }

    public ITM4005VO getSelected() {
        return selected;
    }

    public void setSelected(ITM4005VO selected) {
        this.selected = selected;
    }

    public List<ITM4005VO> getSelecteds() {
        return selecteds;
    }

    public List<ITM4008VO> getFullRankItemSelecteds() {
        return fullRankItemSelecteds;
    }

    public void setFullRankItemSelecteds(List<ITM4008VO> fullRankItemSelecteds) {
        this.fullRankItemSelecteds = fullRankItemSelecteds;
    }

    public List<ITM4008VO> getFullRankItems() {
        return fullRankItems;
    }

    public void setFullRankItems(List<ITM4008VO> fullRankItems) {
        this.fullRankItems = fullRankItems;
    }

    public ITM4008VO getRankItemSelected() {
        return rankItemSelected;
    }

    public void setRankItemSelected(ITM4008VO rankItemSelected) {
        this.rankItemSelected = rankItemSelected;
    }

    public List<ITM4008VO> getRankItems() {
        return rankItems;
    }

    public void setRankItems(List<ITM4008VO> rankItems) {
        this.rankItems = rankItems;
    }

    public void setSelecteds(List<ITM4005VO> selecteds) {
        this.selecteds = selecteds;
    }

    public int getSelectedIndex() {
        return selectedIndex;
    }

    public void setSelectedIndex(int selectedIndex) {
        this.selectedIndex = selectedIndex;
    }
    
    public String getActionFlag() {
        return actionFlag;
    }

    public void setActionFlag(String actionFlag) {
        this.actionFlag = actionFlag;
    }
    
    //</editor-fold>



    
    @Init
    public void init(){
        ITM4005VO vo1 = new ITM4005VO();
        vo1.setPROJ_ID("9001");
        vo1.setPROJ_NO("2015MKT001");
        vo1.setPROJ_NM("DDS Tariff Copy 功能 及 tariff 架構調整");
        vo1.setEFF_DATE("20150101");
        vo1.setEXP_DATE("20150131");
        vo1.setPROJ_TYPE("Requirement");
        vo1.setPROJ_STATUS("Approved");
        
        ITM4005VO vo2 = new ITM4005VO();
        vo2.setPROJ_ID("9002");
        vo2.setPROJ_NO("2015MKT002");
        vo2.setPROJ_NM("WDBKG181:批核時無法同一船名航次搭配同一POL/POD統一批核");
        vo2.setEFF_DATE("20150101");
        vo2.setEXP_DATE("20150228");
        vo2.setPROJ_TYPE("Requirement");
        vo2.setPROJ_STATUS("Approved");
        
        ITM4005VO vo3 = new ITM4005VO();
        vo3.setPROJ_ID("9003");
        vo3.setPROJ_NO("TW201504W01");
        vo3.setPROJ_NM("TXGW TML server/storage EHHAMCEMENT");
        vo3.setEFF_DATE("20150415");
        vo3.setEXP_DATE("20150630");
        vo3.setPROJ_TYPE("Project");
        vo3.setPROJ_STATUS("Approved");
        
        ITM4005VO vo4 = new ITM4005VO();
        vo4.setPROJ_ID("9004");
        vo4.setPROJ_NO("");
        vo4.setPROJ_NM("日本提單作業流程Review");
        vo4.setEFF_DATE("20150501");
        vo4.setEXP_DATE("");
        vo4.setPROJ_TYPE("Project ");
        vo4.setPROJ_STATUS("Draft");
            
        items.add(vo1);
        items.add(vo2);
        items.add(vo3);
        items.add(vo4);
        
        ITM4007VO fileVO1 = new ITM4007VO();
        fileVO1.setSTORE_FILE_NAME("9001_01_WDCMS124.PDF");
        
        ITM4007VO fileVO2 = new ITM4007VO();
        fileVO2.setSTORE_FILE_NAME("9001_02_WDCMS608.DOC");
        
        fileItems.add(fileVO1);
        fileItems.add(fileVO2);
        
        ITM4008VO fullVO1 = new ITM4008VO();
        fullVO1.setRANK_LEVEL("4");
        fullVO1.setUSER_INFO("資訊科技部 TW01000193 許維新");
        ITM4008VO fullVO2 = new ITM4008VO();
        fullVO2.setRANK_LEVEL("3");
        fullVO2.setUSER_INFO("　　系統服務課 TW01000987 徐廉傑");
        ITM4008VO fullVO3 = new ITM4008VO();
        fullVO3.setRANK_LEVEL("2");
        fullVO3.setUSER_INFO("　　　　系統服務課 TW01001152 劉朝明");
        ITM4008VO fullVO4 = new ITM4008VO();
        fullVO4.setRANK_LEVEL("2");
        fullVO4.setUSER_INFO("　　　　系統服務課 TW01001283 鄭偉宏");
        ITM4008VO fullVO5 = new ITM4008VO();
        fullVO5.setRANK_LEVEL("2");
        fullVO5.setUSER_INFO("　　　　系統服務課 TW01001458 林佳宏");
        ITM4008VO fullVO6 = new ITM4008VO();
        fullVO6.setRANK_LEVEL("3");
        fullVO6.setUSER_INFO("　　資訊應用課 TW01001352 吳守仁");
        ITM4008VO fullVO7 = new ITM4008VO();
        fullVO7.setRANK_LEVEL("2");
        fullVO7.setUSER_INFO("　　　　資訊應用課 TW01001294 黃瓊寬");
        ITM4008VO fullVO8 = new ITM4008VO();
        fullVO8.setRANK_LEVEL("2");
        fullVO8.setUSER_INFO("　　　　資訊應用課 TW01001344 林壽昌");
        ITM4008VO fullVO9 = new ITM4008VO();
        fullVO9.setRANK_LEVEL("2");
        fullVO9.setUSER_INFO("　　　　資訊應用課 TW01001379 黃佳敏");
        ITM4008VO fullVO10 = new ITM4008VO();
        fullVO10.setRANK_LEVEL("2");
        fullVO10.setUSER_INFO("　　　　資訊應用課 TW01001732 洪英傑");
        ITM4008VO fullVO11 = new ITM4008VO();
        fullVO11.setRANK_LEVEL("3");
        fullVO11.setUSER_INFO("　　資訊科技部 TW01000808 王靜瑩");
        ITM4008VO fullVO12 = new ITM4008VO();
        fullVO12.setRANK_LEVEL("2");
        fullVO12.setUSER_INFO("　　　　系統設計一課 TW01001058 張富美");
        ITM4008VO fullVO13 = new ITM4008VO();
        fullVO13.setRANK_LEVEL("1");
        fullVO13.setUSER_INFO("　　　　　　系統設計一課 TW01000933 陳怡嘉");
        ITM4008VO fullVO14 = new ITM4008VO();
        fullVO14.setRANK_LEVEL("1");
        fullVO14.setUSER_INFO("　　　　　　系統設計一課 TW01001080 張金蓮");
        ITM4008VO fullVO15 = new ITM4008VO();
        fullVO15.setRANK_LEVEL("1");
        fullVO15.setUSER_INFO("　　　　　　系統設計一課 TW01001169 謝德憲");
        ITM4008VO fullVO16 = new ITM4008VO();
        fullVO16.setRANK_LEVEL("1");
        fullVO16.setUSER_INFO("　　　　　　系統設計一課 TW01001390 張瑞云");
        ITM4008VO fullVO17 = new ITM4008VO();
        fullVO17.setRANK_LEVEL("1");
        fullVO17.setUSER_INFO("　　　　　　系統設計一課 TW01001433 張寶合");
        
        fullRankItems.add(fullVO1);
        fullRankItems.add(fullVO2);
        fullRankItems.add(fullVO3);
        fullRankItems.add(fullVO4);
        fullRankItems.add(fullVO5);
        fullRankItems.add(fullVO6);
        fullRankItems.add(fullVO7);
        fullRankItems.add(fullVO8);
        fullRankItems.add(fullVO9);
        fullRankItems.add(fullVO10);
        fullRankItems.add(fullVO11);
        fullRankItems.add(fullVO12);
        fullRankItems.add(fullVO13);
        fullRankItems.add(fullVO14);
        fullRankItems.add(fullVO15);
        fullRankItems.add(fullVO16);
        fullRankItems.add(fullVO17);
    }
}
